use static const qregularexpressions where possible
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Sat, 19 Mar 2022 14:01:01 +0000 (14:01 +0000)
committertsteven4 <13596209+tsteven4@users.noreply.github.com>
Sat, 19 Mar 2022 14:01:01 +0000 (14:01 +0000)
exif.cc
trackfilter.cc
xcsv.cc

diff --git a/exif.cc b/exif.cc
index 8cf6a936508766348d48da5d707cd223ba21a345..b6679aab7ae2fe0e8094c1f0632fe4cde733b717 100644 (file)
--- a/exif.cc
+++ b/exif.cc
@@ -710,7 +710,7 @@ ExifFormat::exif_get_exif_time(ExifApp* app)
     if (offset_tag) {
       char* time_tag = exif_read_str(offset_tag);
       // string should be +HH:MM or -HH:MM
-      const QRegularExpression re(R"(^([+-])(\d{2}):(\d{2})$)");
+      static const QRegularExpression re(R"(^([+-])(\d{2}):(\d{2})$)");
       assert(re.isValid());
       QRegularExpressionMatch match = re.match(time_tag);
       if (match.hasMatch()) {
index 39b82c27632fe16758c988ae5e03e32a847bda7a..fb5f5f63d4e26304eeb4afd61590a3722b5b0c72 100644 (file)
@@ -75,7 +75,7 @@ qint64 TrackFilter::trackfilter_parse_time_opt(const char* arg)
 {
   qint64 result = 0;
 
-  QRegularExpression re("^([+-]?\\d+)([wdhms])(?:([+-]?\\d+)([wdhms]))?(?:([+-]?\\d+)([wdhms]))?(?:([+-]?\\d+)([wdhms]))?(?:([+-]?\\d+)([wdhms]))?$", QRegularExpression::CaseInsensitiveOption);
+  static const QRegularExpression re("^([+-]?\\d+)([wdhms])(?:([+-]?\\d+)([wdhms]))?(?:([+-]?\\d+)([wdhms]))?(?:([+-]?\\d+)([wdhms]))?(?:([+-]?\\d+)([wdhms]))?$", QRegularExpression::CaseInsensitiveOption);
   assert(re.isValid());
   QRegularExpressionMatch match = re.match(arg);
   if (match.hasMatch()) {
@@ -426,7 +426,7 @@ void TrackFilter::trackfilter_split()
 
     opt_interval = (opt_split && (strlen(opt_split) > 0) && (0 != strcmp(opt_split, TRACKFILTER_SPLIT_OPTION)));
     if (opt_interval != 0) {
-      QRegularExpression re(R"(^([+-]?(?:\d+(?:\.\d*)?|\.\d+))([dhms])$)", QRegularExpression::CaseInsensitiveOption);
+      static const QRegularExpression re(R"(^([+-]?(?:\d+(?:\.\d*)?|\.\d+))([dhms])$)", QRegularExpression::CaseInsensitiveOption);
       assert(re.isValid());
       QRegularExpressionMatch match = re.match(opt_split);
       if (match.hasMatch()) {
@@ -462,7 +462,7 @@ void TrackFilter::trackfilter_split()
 
     opt_distance = (opt_sdistance && (strlen(opt_sdistance) > 0) && (0 != strcmp(opt_sdistance, TRACKFILTER_SDIST_OPTION)));
     if (opt_distance != 0) {
-      QRegularExpression re(R"(^([+-]?(?:\d+(?:\.\d*)?|\.\d+))([km])$)", QRegularExpression::CaseInsensitiveOption);
+      static const QRegularExpression re(R"(^([+-]?(?:\d+(?:\.\d*)?|\.\d+))([km])$)", QRegularExpression::CaseInsensitiveOption);
       assert(re.isValid());
       QRegularExpressionMatch match = re.match(opt_sdistance);
       if (match.hasMatch()) {
@@ -665,7 +665,7 @@ QDateTime TrackFilter::trackfilter_range_check(const char* timestr)
 {
   QDateTime result;
 
-  QRegularExpression re("^(\\d{0,14})$");
+  static const QRegularExpression re("^(\\d{0,14})$");
   assert(re.isValid());
   QRegularExpressionMatch match = re.match(timestr);
   if (match.hasMatch()) {
@@ -826,7 +826,7 @@ TrackFilter::faketime_t TrackFilter::trackfilter_faketime_check(const char* time
 {
   faketime_t result;
 
-  QRegularExpression re(R"(^(f?)(\d{0,14})(?:\+(\d{1,10}))?$)");
+  static const QRegularExpression re(R"(^(f?)(\d{0,14})(?:\+(\d{1,10}))?$)");
   assert(re.isValid());
   QRegularExpressionMatch match = re.match(timestr);
   if (match.hasMatch()) {
diff --git a/xcsv.cc b/xcsv.cc
index 99a9543c05122bdf34fd42e3ba2942ebaed6cf0e..9d9af116bd7277715f3b684263ba0bee4e6e1407 100644 (file)
--- a/xcsv.cc
+++ b/xcsv.cc
@@ -1659,7 +1659,8 @@ XcsvStyle::xcsv_parse_style_line(XcsvStyle* style, QString line)
   }
 
   // Separate op and tokens.
-  int sep = line.indexOf(QRegularExpression(R"(\s+)"));
+  static const QRegularExpression re(R"(\s+)");
+  int sep = line.indexOf(re);
 
   // the first token is the operation, e.g. "IFIELD"
   QString op = line.mid(0, sep).trimmed().toUpper();